// 创建一个组件注册中心，方便扩展
class ComponentRegistry {
  constructor() {
    this.components = new Map();
  }

  register(component) {
    this.components.set(component.code, component);
  }

  getAll() {
    return Array.from(this.components.values());
  }

  getByCode(code) {
    return this.components.get(code);
  }

  getByCategory(category) {
    return this.getAll().filter(comp => comp.category === category);
  }
}

export const componentRegistry = new ComponentRegistry();

// 使用示例
import Button from '../components/Button/index.vue';
import ButtonSet from '../components/Button/set.vue';
import Input from '../components/Input/index.vue';
import InputSet from '../components/Input/set.vue';

// 注册基础组件
componentRegistry.register({
  code: 'button',
  set: 'button-set',
  name: '按钮',
  component: Button,
  configComponent: ButtonSet,
  defaultProps: { type: 'primary', value: '默认' },
  category: 'basic'
});

componentRegistry.register({
  code: 'input',
  set: 'input-set',
  name: '输入框',
  component: Input,
  configComponent: InputSet,
  defaultProps: { placeholder: '请输入内容', value: '' },
  category: 'form'
});